<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs for page functions.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
			<div class="page-body">			
<h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style="vertical-align: middle">/scripts/functions.php</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
															<a href="#sec-functions">Functions</a>
			</div>
	<div class="info-box-body">	
		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">PSA functions.</p>
<p class="description"><p>LICENSE:</p><p>This library is free software: you can redistribute it and/or modify  it under the terms of the GNU Lesser General Public License as published by  the Free Software Foundation, either version 3 of the License, or  (at your option) any later version.</p><p>This library is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  GNU Lesser General Public License for more details.</p><p>You should have received a copy of the GNU Lesser General Public License  along with This library. If not, see &lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;.</p></p>
	<ul class="tags">
				<li><span class="field">author:</span> Bojan Mauser &lt;<a href="mailto:bmauser@gmail.com">bmauser@gmail.com</a>&gt;</li>
				<li><span class="field">version:</span> $Id: functions.php 464 2009-03-24 00:30:12Z bmauser $</li>
				<li><span class="field">copyright:</span> Bojan Mauser 2009</li>
				<li><span class="field">link:</span> <a href="http://code.google.com/p/phpstartapp/">http://code.google.com/p/phpstartapp/</a></li>
				<li><span class="field">filesource:</span> <a href="../__filesource/fsource_psa__scriptsfunctions.php.html">Source Code for this file</a></li>
			</ul>
		
			</div>
</div>
		

	
	
	
	<a name="sec-functions"></a>	
	<div class="info-box">
		<div class="info-box-title">Functions</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
															<span class="disabled">Functions</span>
		</div>
		<div class="info-box-body">	
			<a name="functionpsa_add_include_path" id="functionpsa_add_include_path"><!-- --></a>
<div class="oddrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_add_include_path</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a654">654</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Adds given path to PHP include_path configuration directive.</p>
<p class="description"><p>It can be useful when you work with some externals libraries like Zend Framework.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> returns the old include_path on success or FALSE on failure.</li>
				<li><span class="field">see:</span> ini.include-path</li>
			</ul>
	<div class="method-signature">
		<span class="method-result">string|bool</span>
		<span class="method-name">
			psa_add_include_path
		</span>
					(<span class="var-type">string</span>&nbsp;<span class="var-name">$path</span>)
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$path</span><span class="var-description">: path to add to include path</span>			</li>
				</ul>
		
	
</div>
<a name="functionpsa_autoload" id="functionpsa_autoload"><!-- --></a>
<div class="evenrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_autoload</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a446">446</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">This function is registered with PHP spl_autoload_register() function as __autoload() implementation  used to auto include files with PSA plugin classes or your plugins.</p>
<p class="description"><p>Thus you don't have to put <kbd>include()</kbd> call to include file with <em>Psa_Plugin_</em>  abstract class in every your plugin file before you extend some <em>Psa_Plugin_</em> class.</p><p>Also if you want to call a method from some another plugin class, or extend some plugin class,  you don't have to include its file.</p><p>For example, you can just write:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-key">class&nbsp;</span><span class="src-id">Default_Controller&nbsp;</span><span class="src-key">extends&nbsp;</span><a href="../psa/plugins/Psa_Plugin_Controller.html">Psa_Plugin_Controller</a><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">function&nbsp;</span><span class="src-id">psa_main</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">{</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;...&nbsp;something&nbsp;here</span></div></li>
<li><div class="src-line">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-php">?&gt;</span></div></li>
</ol></div></p></p>
	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			psa_autoload
		</span>
					(<span class="var-type"></span>&nbsp;<span class="var-name">$class_name</span>)
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type"></span>
				<span class="var-name">$class_name</span>			</li>
				</ul>
		
	
</div>
<a name="functionpsa_get_backtrace" id="functionpsa_get_backtrace"><!-- --></a>
<div class="oddrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_get_backtrace</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a179">179</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Calls <kbd>debug_backtrace()</kbd> PHP function and returns formatted backtrace string.</p>
<p class="description"><p>It is used for logs.  Example of returned string:<pre> query() called at [/WEBROOT/bf/psa/scripts/Psa_User.class.php:391]
 add_remove_group() called at [/WEBROOT/bf/psa/scripts/Psa_User.class.php:327]
 add_group() called at [/WEBROOT/bf/index.php:17]</pre></p></p>
	<div class="method-signature">
		<span class="method-result">string</span>
		<span class="method-name">
			psa_get_backtrace
		</span>
				()
			</div>

		
	
</div>
<a name="functionpsa_group_del" id="functionpsa_group_del"><!-- --></a>
<div class="evenrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_group_del</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a163">163</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Deletes group. Removes all data about the group from database.</p>
<p class="description"><p>If you want to delete group by id be sure to pass integer as argument (or array of integers)  and use cast operator <kbd>(int)</kbd></p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 0 for failure, 1 for success, -1 group (or more groups) not exists</li>
			</ul>
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			psa_group_del
		</span>
					(<span class="var-type">int|array|string</span>&nbsp;<span class="var-name">$group</span>)
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">int|array|string</span>
				<span class="var-name">$group</span><span class="var-description">: ID or name of the group or array with group ids or group names.  <kbd>all</kbd> to delete all groups.</span>			</li>
				</ul>
		
	
</div>
<a name="functionpsa_is_user_in_group" id="functionpsa_is_user_in_group"><!-- --></a>
<div class="oddrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_is_user_in_group</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a548">548</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Checks if user is a member of a group.</p>
<p class="description"><p>It simply tries to find a matching row in <em>psa_user_in_group</em> database table.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1-user is a member of the group, otherwise 0</li>
			</ul>
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			psa_is_user_in_group
		</span>
					(<span class="var-type">int</span>&nbsp;<span class="var-name">$user</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$group</span>)
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">int</span>
				<span class="var-name">$user</span><span class="var-description">: user id</span>			</li>
					<li>
				<span class="var-type">int</span>
				<span class="var-name">$group</span><span class="var-description">: group id</span>			</li>
				</ul>
		
	
</div>
<a name="functionpsa_request_info_html" id="functionpsa_request_info_html"><!-- --></a>
<div class="evenrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_request_info_html</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a589">589</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Returns HTML code with request information.</p>
<p class="description"><p>Request information can be nicely shown on the web page you develop by including  html code returned by this function.  You can put HTML returned somewhere on the web pages and see information like  all plugins that are called, <a href="../psa/Psa_Result.html">Psa_Result</a> object, $_GET, $_POST, $_SESSION,  plugin methods arguments... That can be very useful while developing and debugging.  See example <a href="../psa/tutorial_psa_features.pkg.html#requestinfo">here</a>.</p><p>The template file this function expects is <em>psa_request_info.tpl</em> and it is  by default in PSA main directory. Develop mode must be on to enable collecting request  information. You can enable it through main settings in <a href="../psa/_config.php.html">config.php</a> file.  Actually request information is saved in <a href="../psa/Psa_Registry.html">Psa_Registry</a> object in  <kbd>psa_request_info</kbd> member array and this function is reading it form there.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> rendered template - HTML code, false if develop mode is not on.</li>
			</ul>
	<div class="method-signature">
		<span class="method-result">bool|string</span>
		<span class="method-name">
			psa_request_info_html
		</span>
					([<span class="var-type">string</span>&nbsp;<span class="var-name">$tpl_folder</span> = <span class="var-default">null</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">string</span>
				<span class="var-name">$tpl_folder</span><span class="var-description">: folder where is <em>psa_request_info.tpl</em> template file.  If not set PSA main folder is used.</span>			</li>
				</ul>
		
	
</div>
<a name="functionpsa_run_plugins" id="functionpsa_run_plugins"><!-- --></a>
<div class="oddrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_run_plugins</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a246">246</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Calls plugin methods. Executes (runs) plugins.</p>
<p class="description"><p>This function includes plugin files, makes new instances of plugin objects named like plugin class  and calls member methods.  It can call plugin's methods in two different ways depending on second argument.  If the second argument is false (default) plugins are called <em>by id</em> (plugin id is same  as plugin class name) and in this case first argument should be array with elements  like in this example:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;$run&nbsp;is&nbsp;array&nbsp;that&nbsp;will&nbsp;be&nbsp;argument&nbsp;for&nbsp;psa_run_plugins()&nbsp;function</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;Structure&nbsp;should&nbsp;be:&nbsp;$run['plugin_id']['plugin_method']&nbsp;=&nbsp;array('method_argument1','method_argument2',...);</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$run</span><span class="src-sym">[</span><span class="src-str">'Article'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'load'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-num">14</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$run</span><span class="src-sym">[</span><span class="src-str">'News'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'open'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<a href="../psa/_scripts---functions.php.html#functionpsa_run_plugins">psa_run_plugins</a><span class="src-sym">(</span><span class="src-var">$run</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol></div>  This example calls method <kbd>load</kbd> with one argument (14) from the <kbd>Article</kbd> class  (plugin) instanced as object named <kbd>Article</kbd> and method <kbd>open</kbd> with no arguments  from the <kbd>News</kbd> class instanced as object named <kbd>News</kbd>.</p><p>If the second argument is true plugins are called <em>by type</em> and in this case first argument  should be an array with elements like in example below:  <div class="src-code"><ol><li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;$run&nbsp;is&nbsp;array&nbsp;that&nbsp;will&nbsp;be&nbsp;argument&nbsp;for&nbsp;psa_run_plugins()&nbsp;function</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-comm">//&nbsp;Structure&nbsp;should&nbsp;be:&nbsp;$run['plugin_type']['plugin_method']&nbsp;=&nbsp;array('method_argument1','method_argument2',...);</span></div></li>
<li><div class="src-line">&nbsp;<span class="src-var">$run</span><span class="src-sym">[</span><span class="src-str">'Psa_Plugin_Before_User_Delete'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-str">'psa_main'</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-num">177</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line">&nbsp;<a href="../psa/_scripts---functions.php.html#functionpsa_run_plugins">psa_run_plugins</a><span class="src-sym">(</span><span class="src-var">$run</span><span class="src-sym">,</span><span class="src-str">'by_type'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol></div>  This example calls method <kbd>psa_main</kbd> with one argument (177) from all registered plugins  of type <kbd>Psa_Plugin_Before_User_Delete</kbd>.</p><p>This function will throw <a href="../psa/exceptions/Psa_Exception.html">Psa_Exception</a> on error.</p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 1:success all plugins executed, -1:success, but not with all plugins because some are  probably not registered. -1 can be returned only when third argument is set to true otherwise  exception will be thrown.  Some are probably not registered. See log for details.</li>
				<li><span class="field">see:</span> <a href="../psa/Psa_Plugin.html#methodregister">Psa_Plugin::register()</a></li>
				<li><span class="field">throws:</span> Psa_Exception</li>
			</ul>
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			psa_run_plugins
		</span>
					(<span class="var-type">array</span>&nbsp;<span class="var-name">$run_details</span>, [<span class="var-type">bool</span>&nbsp;<span class="var-name">$by_type</span> = <span class="var-default">false</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$disable_unregistered_exception</span> = <span class="var-default">false</span>])
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">array</span>
				<span class="var-name">$run_details</span><span class="var-description">: array with details what to run</span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$by_type</span><span class="var-description">: if true plugins will be called <em>by type</em> otherwise will be called <em>by id</em></span>			</li>
					<li>
				<span class="var-type">bool</span>
				<span class="var-name">$disable_unregistered_exception</span><span class="var-description">: exception that plugin is not registered will not be thrown.  This parameter can be set to true when plugin doesn't have to be registered like  <a href="../psa/plugins/Psa_Plugin_After_User_Create.html">Psa_Plugin_After_User_Create</a>.</span>			</li>
				</ul>
		
	
</div>
<a name="functionpsa_user_del" id="functionpsa_user_del"><!-- --></a>
<div class="evenrow">
	
	<div>
		<img src="../media/images/Function.png" />
		<span class="method-title">psa_user_del</span> (line <span class="line-number"><a href="../__filesource/fsource_psa__scriptsfunctions.php.html#a147">147</a></span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Deletes user. Removes all data about the user from database.</p>
<p class="description"><p>If you want to delete user by id be sure to pass integer as argument (or array of integers)  and use cast operator <kbd>(int)</kbd></p></p>
	<ul class="tags">
				<li><span class="field">return:</span> 0 for failure, 1 for success, -1 user (or more users) not exists</li>
			</ul>
	<div class="method-signature">
		<span class="method-result">int</span>
		<span class="method-name">
			psa_user_del
		</span>
					(<span class="var-type">int|array|string</span>&nbsp;<span class="var-name">$user</span>)
			</div>

			<ul class="parameters">
					<li>
				<span class="var-type">int|array|string</span>
				<span class="var-name">$user</span><span class="var-description">: ID or username of the user or array with user  ids or usernames. <kbd>all</kbd> to delete all users.</span>			</li>
				</ul>
		
	
</div>
		</div>
	</div>
	
	<p class="notes" id="credit">
		Documentation generated on Thu, 21 Oct 2010 01:40:48 +0200 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
	</p>
	</div></body>
</html>